package com.example.demospringmybatisplus.service;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.demospringmybatisplus.mapper.NodeMapper;
import com.example.demospringmybatisplus.vo.NodeVo;

/**
 * NodeService接口
 *
 * @author huahua
 * @DATE 2024/9/28
 **/
@Service
public class NodeService {
    @Autowired
    private NodeMapper nodeMapper;
    public List<String> getNodeListByName(String name){
        // 通过sql语句中distinct去重
        return nodeMapper.getNodeListByName(name);
    }

    public Set<String> getNodeSetByName(String name){
        // 通过set集合去重
        return nodeMapper.getNodeSetByName(name);
    }

    public List<String> getNodeListNoDistinctByName(String name){
        // 通过xxx.stream().distinct()去重
        List<String> nodeListNoDistinctByName = nodeMapper.getNodeListNoDistinctByName(name);
        return nodeListNoDistinctByName.stream().distinct().collect(Collectors.toList());
    }

    public List<NodeVo> getNodeListNoEmptyNameByEsn(String esn){
        return nodeMapper.getNodeListNoEmptyNameByEsn(esn);
    }

    public List<NodeVo> getNodeListByEsn(String esn){
        return nodeMapper.getNodeListByEsn(esn);
    }
}
